<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class HomeUserStow extends Model
{
	//用户收藏表
    protected $table = 'shop_users_stows';

    //判断该商品用户是否收藏
    public static function hasStow($goods_id)
    {
        $user_id = session('Homeuser-data')['id'];

        $goods = \App\Model\HomeUserStow::select('goods_id')->where('user_id', $user_id)->get()->toArray();

        $arr = [];

        foreach($goods as $v) {

          $arr[] = $v['goods_id'];

        }

        if(in_array($goods_id, $arr)) {

          return false;
        }

        return true;

    }

    //判断用户是否登录
    public static function ifAuth()
    {

        if(empty(session('Homeuser-data'))) {

            return false;

        }

      return true;

    }
}
